<template>
  <div v-if="!isLogin" @click="router.push('/login')" class="p-2 bg-sky-600 text-sm rounded-full size-12 flex items-center justify-center cursor-pointer">
    登录
  </div>
  <div v-if="isLogin" @click="logout" class="p-2 bg-sky-600 text-sm rounded-full size-12 flex items-center justify-center cursor-pointer">
    退登
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()

const isLogin = localStorage.getItem('token')


const login = () => {
  if (userInfo.username === 'admin' && userInfo.password === '123456') {
    localStorage.setItem('token', '123456')
    router.push('/')
  } else {
    alert('用户名或密码错误')
  }
}

const logout = () => {
  localStorage.removeItem('token')
  router.push('/login')
}
</script>

<style lang='scss' scoped>

</style>